package com.example.SpringBootRestful.controller;


import com.example.SpringBootRestful.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping
public class UserController {

    @Autowired
    public UserService userService;
// 1. 实现一个Get请求,查出所有的用户信息
// 2. 接口访问地址：（/api/users）
// 3. 使用注解：@CrossOrigin实现跨域请求。
    @GetMapping("/api/users")
    @CrossOrigin()

    public ResponseEntity getAllUser(){
    return new ResponseEntity<>(userService.getAllUser(), HttpStatus.OK);
    }
}
